package com.pshdhx.aiagent.aitools;

import org.springframework.ai.tool.ToolCallback;
import org.springframework.ai.tool.ToolCallbacks;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author pansd
 * @Date 2025-07-10 12:05
 * @Des AI调用的工具注册
 */
@Configuration
public class ToolRegisterCfg {
    @Value("${searchapi.api-key}")
    private String searchApiKey;

    @Bean
    public ToolCallback[] allTools() {
        FileTool fileOperationTool = new FileTool();
        WebSearchTool webSearchTool = new WebSearchTool(searchApiKey);
        WebScrapingTool webScrapingTool = new WebScrapingTool();
        ResourceDownloadTool resourceDownloadTool = new ResourceDownloadTool();
        TerminalTool terminalOperationTool = new TerminalTool();
        PdfGenerationTool pdfGenerationTool = new PdfGenerationTool();
        TerminateTool terminalTool = new TerminateTool();
        return ToolCallbacks.from(
                fileOperationTool,
                webSearchTool,
                webScrapingTool,
                resourceDownloadTool,
                terminalOperationTool,
                pdfGenerationTool,
                terminalTool
        );
    }
}

